home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Graphics 2D / Restore Screen Cluts / PictDocument.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  11.2 KB  |  337 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        PictDocument.h
  3.  
  4.     Contains:    Header file for the Picture Document routines
  5.  
  6.     Written by: Forrest Tanaka    
  7.  
  8.     Copyright:    Copyright © 1988-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/13/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. #ifndef __PICTDOCUMENT__
  24. #define __PICTDOCUMENT__
  25.  
  26.  
  27. #ifndef THINK_C
  28. #ifndef __WINDOWS__
  29. #include <Windows.h>
  30. #endif
  31.  
  32. #ifndef __FILES__
  33. #include <Files.h>
  34. #endif
  35. #endif
  36.  
  37. /******************************************************************************\
  38. * NAME & SYNOPSIS:
  39. * FindPictDoc: Find the Picture Document window for a specific file
  40. *
  41. * PARAMETERS:
  42. * FSSpecPtr fileSpec: Specification of file to search for
  43. *
  44. * DEFINITION:
  45. * FindPictDoc finds the Picture Document window associated with the file
  46. * specified by fileSpec.  A pointer to this window is returned.  If no matching
  47. * Picture Document window could be found, then nil is returned.
  48. *
  49. * RETURN VALUES:
  50. * Result: Pointer to the Picture Document window that’s associated with the file
  51. *         that’s specified by the fileSpec parameter.
  52. \******************************************************************************/
  53.  
  54. WindowPtr FindPictDoc(
  55.     FSSpecPtr fileSpec);
  56.  
  57.  
  58. /******************************************************************************\
  59. * NAME & SYNOPSIS:
  60. * NextPictDocWindow: Return a pointer to the next Picture Document window
  61. *
  62. * PARAMETERS:
  63. * WindowPtr aWindow: Window to start search from, or nil if want front-most
  64. *
  65. * DEFINITION:
  66. * This routine returns a pointer to the first Picture Document window in the
  67. * window list AFTER the window specified by aWindow.  If aWindow is nil, then
  68. * NextPictDocWindow returns a pointer to the first Picture Document window in
  69. * the window list (ie the front-most Picture Document window.  If no Picture 
  70. * Document windows could be found, then nil is returned.
  71. *
  72. * RETURN VALUES:
  73. * Result: Pointer to the Picture Document window that’s after the window that’s
  74. *         specified by the aWindow parameter.  If aWindow is nil, a pointer to
  75. *         the front-most Picture Document window is returned.
  76. \******************************************************************************/
  77.  
  78. WindowPtr NextPictDocWindow(
  79.     WindowPtr aWindow);
  80.  
  81.  
  82. /******************************************************************************\
  83. * NAME & SYNOPSIS:
  84. * IsPictDocWindow: Is a window a Picture Document window?
  85. *
  86. * PARAMETERS:
  87. * WindowPtr aWindow: Window to test for Picture Document-ness
  88. *
  89. * DEFINITION:
  90. * When it needs to be determined whether a window is a Picture Document window
  91. * or not, this routine is called.  It returns true if aWindow is a Picture
  92. * Document window, or false if not.  If aWindow is nil, then false is returned.
  93. *
  94. * RETURN VALUES:
  95. * Result: Boolean true if the aWindow parameter refers to a Picture Document
  96. *         window; false if not.
  97. \******************************************************************************/
  98.  
  99. Boolean IsPictDocWindow(
  100.     WindowPtr aWindow);
  101.  
  102.  
  103. /******************************************************************************\
  104. * NAME & SYNOPSIS:
  105. * DrawPictDoc: Draw the contents of a Picture Document
  106. *
  107. * PARAMETERS:
  108. * WindowPtr docWindow: Ptr to Picture Document window being drawn
  109. *
  110. * DEFINITION:
  111. * The contents of the Picture Document window specified by docWindow are
  112. * drawn into the window.  The contents include the image, the scroll bars, and
  113. * the grow icon.  This routine is called in response to update events.
  114. *
  115. * RETURN VALUES:
  116. * None
  117. \******************************************************************************/
  118.  
  119. void DrawPictDoc(
  120.     WindowPtr docWindow);
  121.  
  122.  
  123. /******************************************************************************\
  124. * NAME & SYNOPSIS:
  125. * ClickPictDoc: Handle a mouse click in a Picture Document window
  126. *
  127. * PARAMETERS:
  128. * WindowPtr   docWindow:   Pointer to Picture Document window that was clicked
  129. * EventRecord *clickEvent: Event that recorded the mouse click
  130. *
  131. * DEFINITION:
  132. * Whenever there’s a mouse-down event in a Picture Document window, this routine
  133. * is called to handle the mouse click.  There are two cases in which there can
  134. * be a mouse click in a Picture Document window and ClickPictDoc is not called:
  135. * if the title bar of a window is clicked, DoWindowDrag in ColorReset.c is
  136. * called to let the user move the window; if the grow icon is clicked,
  137. * GrowPictDoc, defined below, is called to let the user change the size of the
  138. * window.
  139. *
  140. * ClickPictDoc handles mouse clicks in the image within the Picture Document
  141. * window by letting the user draw paint into the image.  Clicks in either of the
  142. * two scroll bars are handled by scrolling the image in the way that the user
  143. * wants.
  144. *
  145. * RETURN VALUES:
  146. * None
  147. \******************************************************************************/
  148.  
  149. void ClickPictDoc(
  150.     WindowPtr   docWindow,
  151.     EventRecord *clickEvent);
  152.  
  153.  
  154. /******************************************************************************\
  155. * NAME & SYNOPSIS:
  156. * GrowPictDoc: Let the user change the size of a Picture Document window
  157. *
  158. * PARAMETERS:
  159. * WindowPtr   docWindow:   Picture Document window that’s to be grown
  160. * EventRecord *clickEvent: Mouse down event
  161. *
  162. * DEFINITION:
  163. * GrowPictDoc is called whenever there’s a click in the grow icon of a Picture
  164. * Document window.  It lets the user grow and shrink the window until he or she
  165. * lets go of the mouse button.  The Picture Document window is then updated for
  166. * the new size of the window.
  167. *
  168. * DESCRIPTION:
  169. * GrowWindow is called with a boundary rectangle that specifies that the window
  170. * has a minimum size of kMinWindowSize (defined at the top of this source file)
  171. * and a maximum size that’s the size of the image.  After the user releases the
  172. * mouse button, SizeWindow is called to change the size of the window, and
  173. * ResizePictDoc (defined below) is called to update the Picture Document to the
  174. * new size.
  175. *
  176. * RETURN VALUES:
  177. * None
  178. \******************************************************************************/
  179.  
  180. void GrowPictDoc(
  181.     WindowPtr   docWindow,
  182.     EventRecord *clickEvent);
  183.  
  184.  
  185. /******************************************************************************\
  186. * NAME & SYNOPSIS:
  187. * ActivatePictDoc: Activate or deactivate a Picture Document window
  188. *
  189. * PARAMETERS:
  190. * WindowPtr docWindow:      Picture Document window that’s being (de)activated
  191. * Boolean   becomingActive: True if window is becoming active; false otherwise
  192. *
  193. * DEFINITION:
  194. * ActivatePictDoc is called whenever a Picture Document window is activated or
  195. * deactivated.  This is just to handle the visual aspects of window activation,
  196. * such as hiding or showing the grow icon and the scroll bars.
  197. *
  198. * RETURN VALUES:
  199. * None
  200. \******************************************************************************/
  201.  
  202. void ActivatePictDoc(
  203.     WindowPtr docWindow,
  204.     Boolean   becomingActive);
  205.  
  206.  
  207. /******************************************************************************\
  208. * NAME & SYNOPSIS:
  209. * FixPictDocMenus: Enable or check menus for Picture Documents
  210. *
  211. * PARAMETERS:
  212. * WindowPtr docWindow: Picture Document to apply menu dimming to
  213. *
  214. * DEFINITION:
  215. * FixPictDocMenus is called whenever the state of the menus associated with a
  216. * Picture Document window is changed, like when a Picture Document is opened, or
  217. * if some state of the Picture Document has changed.  FixPictDocMenus only
  218. * enables or checks menu items; it doesn’t disable or uncheck items.  Disabling
  219. * and unchecking is handled in MenuHandler.c.
  220. *
  221. * RETURN VALUES:
  222. * None
  223. \******************************************************************************/
  224.  
  225. void FixPictDocMenus(
  226.     WindowPtr docWindow);
  227.  
  228.  
  229. /******************************************************************************\
  230. * NAME & SYNOPSIS:
  231. * DoOpenPictDoc: Open a new Picture Document
  232. *
  233. * PARAMETERS:
  234. * None
  235. *
  236. * DEFINITION:
  237. * When the user chooses Open… from the file menu to open an existing Picture
  238. * Document file (really a PICT file).  The user is asked which PICT file to
  239. * open, and then a new window appears with the picture displayed in it.  A
  240. * pointer to this window is returned.  If the Picture Document couldn’t be
  241. * opened for some reason, an alert is displayed which tells the user what went
  242. * wrong, and no Picture Document window is opened.
  243. *
  244. * If the Picture Document is already open from another application, then it
  245. * can’t be opened from this application, and an alert is given to the user.  If
  246. * the Picture Document is already open within this application, then that
  247. * document’s window is simply activated and its pointer is returned.
  248. *
  249. * RETURN VALUES:
  250. * Result: Pointer to the new Picture Document window.  If a Picture Document
  251. *         window couldn’t be created, nil is returned.
  252. \******************************************************************************/
  253.  
  254. WindowPtr DoOpenPictDoc(void);
  255.  
  256.  
  257. /******************************************************************************\
  258. * NAME & SYNOPSIS:
  259. * DoSaveAsPictDoc: Save a new Picture Document
  260. *
  261. * PARAMETERS:
  262. * WindowPtr docWindow: Pointer to Picture Document window being saved
  263. *
  264. * DEFINITION:
  265. * This routine is called when the user chooses Save As… from the File menu.  It
  266. * saves a new Picture Document as a PICT file.
  267. *
  268. * RETURN VALUES:
  269. * None
  270. \******************************************************************************/
  271.  
  272. void DoSaveAsPictDoc(
  273.     WindowPtr docWindow);
  274.  
  275.  
  276. /******************************************************************************\
  277. * NAME & SYNOPSIS:
  278. * DoClosePictDoc: Close a Picture Document window
  279. *
  280. * PARAMETERS:
  281. * WindowPtr docWindow: Pointer to Picture Document window being closed
  282. *
  283. * DEFINITION:
  284. * This routine closes the Picture Document window specified by the
  285. * docWindow parameter.  All memory associated with the window is disposed
  286. * of and the window is closed.  At this time, true is always returned.
  287. *
  288. * RETURN VALUES:
  289. * Result: Always true
  290. \******************************************************************************/
  291.  
  292. Boolean DoClosePictDoc(
  293.     WindowPtr docWindow);
  294.  
  295.  
  296. /******************************************************************************\
  297. * NAME & SYNOPSIS:
  298. * ChooseBrushColor: Choose a color for the brush
  299. *
  300. * PARAMETERS:
  301. * WindowPtr docWindow: Window whose brush color is to be chosen
  302. *
  303. * DEFINITION:
  304. * When the user chooses Brush Color… from the Color menu, this routine is called
  305. * to present the Color Picker to the user so that he or she can choose a new
  306. * color for the brush.
  307. *
  308. * RETURN VALUES:
  309. * None
  310. \******************************************************************************/
  311.  
  312. void ChooseBrushColor(
  313.     WindowPtr docWindow);
  314.     
  315. pascal void ScrollActionProc(
  316.     ControlHandle control, /* Handle to clicked control */
  317.     short         part);   /* Part number of clicked control part */
  318.  
  319. pascal void InfoBits(
  320.     BitMapPtr srcBits,
  321.     Rect      *srcRect,
  322.     Rect      *dstRect,
  323.     short     mode,
  324.     RgnHandle maskRgn);
  325.     
  326. pascal void FileGetPic(
  327.     Ptr   dataPtr,
  328.     short byteCount);
  329.  
  330. pascal void FilePutPic(
  331.     Ptr   dataPtr,
  332.     short byteCount);
  333.  
  334.  
  335.  
  336. #endif
  337.